﻿#include "about.h"
#include "ui_about.h"
#include <QDesktopServices>
#include <QUrl>
#include "myapp.h"
#include <QProcess>
#include <QMessageBox>

about::about(QString softversion, QWidget* parent) :
    QWidget(parent),
    ui(new Ui::about)
{
    ui->setupUi(this);
    this->setWindowFlags(Qt::FramelessWindowHint );
    m_soft = softversion;
    ui->lab_softwareve->setText(m_soft);
}

about::~about()
{
    delete ui;
}

void about::on_btn_userhelp_clicked()
{

    QString pdfFile = myApp::AppPath + "PTU软件用户手册—V1.0.pdf";
    QDesktopServices::openUrl(QUrl::fromLocalFile(pdfFile));
}
/*
 @ Kind   : Add
 @ Author : Wei.Liu
 @ Date   : 2022-09-06
 @ Brief  : upgrade
*/
void about::on_btn_upgrade_clicked()
{
    if(QMessageBox::question(nullptr, "请求", "升级时需关闭软件，是否立即关闭软件？") == QMessageBox::Yes)
    {
        QProcess process;
        //传入路径中有空格，为避免这种状况，在启动的时候传入的exe路径需要用\"包起来
        QString str = "\"" +  QApplication::applicationDirPath() + "/updater.exe" + "\"";
        process.startDetached(str);
        this->parentWidget()->close();
    }

}
